Skip to content

Implemented with ES6 classes, additional functionality. #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AnnaYasenova
Copy link

Implemented next methods: searchPos, remove, findFirst, findAll, find.


}

searchPos(searchPosition) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше itemAtPos(position)

findFirst(name) {
let current = this.first;

while (current !== null && current.name !== name) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно даже current && current.name !== name

let position = 0;

if (this.length < 0 || removePosition >= this.length) {
throw new Error('Position out of bounds.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не принято ошибки бросать по таким поводам, лучше вернуть ошибку или false из функции

let current = this.first;
let position = 0;

if (this.length === 0 ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Форматирование этого длинного условия нужно как-то причесать. Я думаю, что если разобраться в сути, то условие будет покороче.

Copy link
Member

@tshemsedinov tshemsedinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В общем все ок

}

return current;
}

remove(removePosition) {
remove(remPos) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше просто pos, не нужно дублировать имя функции в ее аргументах

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants